<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Welcome  to  index</title>
</head>
<body>
    <span th:text="bjsxt"></span>
    <hr/>
    <span th:text="${msg}"></span>
    <hr/>
    <input th:value="${msg}" />


    <hr/><hr/><h1 align="center">字符串操作</h1><hr/><hr/>
    <hr/>
    判断字符串是否为空：
    <span th:text="${#strings.isEmpty(msg)}"></span>
    <hr/>
    判断字符串是否包含这个字符：
    <span th:text="${#strings.contains(msg,'T')}"></span>
    <hr/>
    判断字符串是否以这个字符开头：
    <span th:text="${#strings.startsWith(msg,'T')}"></span>
    <hr/>
    判断字符串是否以这个字符结尾：
    <span th:text="${#strings.endsWith(msg,'f')}"></span>
    <hr/>
    返回字符串的长度：
    <span th:text="${#strings.length(msg)}"></span>
    <hr/>
    返回指定字符的下标：
    <span th:text="${#strings.indexOf(msg,'e')}"></span>
    <hr/>
    截取字符串(从下标为3开始截取)：
    <span th:text="${#strings.substring(msg,3)}"></span>
    <hr/>
    截取字符串0-3(不包括下标为3的)：
    <span th:text="${#strings.substring(msg,0,3)}"></span>
    <hr/>
    转小写：
    <span th:text="${#strings.toLowerCase(msg)}"></span>
    <hr/>
    转大写：
    <span th:text="${#strings.toUpperCase(msg)}"></span>


    <hr/><hr/><h1 align="center">日期格式化处理</h1><hr/><hr/>
    <hr/>
    获取当前浏览器的时间：
    <span th:text="${#dates.format(date)}"></span>
    <hr/>
    将时间的格式转换：
    <span th:text="${#dates.format(date,'yyyy/MM/dd')}"></span>
    <hr/>
    获取当前的年份：
    <span th:text="${#dates.year(date)}"></span>
    <hr/>
    获取当前的月份：
    <span th:text="${#dates.month(date)}"></span>
    <hr/>
    获取当前的日份：
    <span th:text="${#dates.day(date)}"></span>


    <hr/><hr/><h1 align="center">Thymeleaf的条件判断</h1><hr/><hr/>
    <hr/>
    <div>
        <span th:if="${sex} == '男'">
            性别：男
        </span>
        <span th:if="${sex} == '女'">
            性别：女
        </span>
    </div>
    <div th:switch="${id}">
        <span th:case="1">判断结果：ID为1</span>
        <span th:case="2">判断结果：ID为2</span>
        <span th:case="3">判断结果：ID为3</span>
        <span th:case="4">判断结果：ID为4</span>
        <span th:case="*">判断结果：ID为*</span>
    </div>

    <hr/><hr/><h1 align="center">Thymeleaf的迭代遍历</h1><hr/><hr/>
    <hr/>
    <table border="1px" width="50%">
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Age</th>
        </tr>
        <tr th:each="u : ${list}" align="center">
            <td th:text="${u.id}"></td>
            <td th:text="${u.name}"></td>
            <td th:text="${u.age}"></td>
        </tr>
    </table>

    <hr/><hr/><h1 align="center">th:each的状态变量</h1><hr/><hr/>
    <hr/>
    <table border="1px" width="50%">
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Age</th>

            <th>Index</th>
            <th>Count</th>
            <th>Size</th>
            <th>Odd</th>
            <th>Even</th>
            <th>First</th>
            <th>Last</th>
        </tr>
        <tr th:each="u,sb : ${list}" align="center">
            <td th:text="${u.id}"></td>
            <td th:text="${u.name}"></td>
            <td th:text="${u.age}"></td>

            <td th:text="${sb.index}"></td>
            <td th:text="${sb.count}"></td>
            <td th:text="${sb.size}"></td>
            <td th:text="${sb.odd}"></td>
            <td th:text="${sb.even}"></td>
            <td th:text="${sb.first}"></td>
            <td th:text="${sb.last}"></td>
        </tr>
    </table>



    <hr/><hr/><hr/><h1 align="center">th:each迭代Map</h1><hr/><hr/>
    <hr/>
    <table border="1px" width="50%">
        <tr>
            <th>Value</th>
        </tr>
        <tr th:each="m : ${map}" align="center">
            <td th:text="${m}"></td>
        </tr>
    </table>

    <hr/>
    <table border="1px" width="50%">
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Age</th>
            <th>Key</th>
        </tr>
        <tr th:each="m1 : ${map}" align="center">
            <td th:text="${m1.value.id}"></td>
            <td th:text="${m1.value.name}"></td>
            <td th:text="${m1.value.age}"></td>
            <td th:text="${m1.key}"></td>
        </tr>
    </table>

    <hr/><hr/><hr/><h1 align="center">操作域对象</h1><hr/><hr/>
    <hr/>
    HttpServletRequest:<span th:text="${#request.getAttribute('req')}" />
                       <span th:text="${#httpServletRequest.getAttribute('req')}" />
    <hr/>
    HttpSession:<span th:text="${session.ses}" />
                <span th:text="${#httpSession.getAttribute('ses')}" />
    <hr/>
    Application:<span th:text="${application.app}" />
                <span th:text="${#servletContext.getAttribute('app')}" />

    <hr/><hr/><hr/><h1 align="center">URL表达式</h1><hr/><hr/>
    <hr/>
    测试绝对路径：
    <a th:href="@{http://www.baidu.com}">打开百度</a>
    <hr/>
    测试相对路径：
    <a th:href="@{/show2}">跳转到Index2</a>

    <h1>URL中参数的传递：</h1>
    <a th:href="@{/show2?id=1&name=admin}">普通URL传递参数方式一</a>
    <hr/>
    <a th:href="@{/show2(id=2,name=kevin)}">普通URL传递参数方式二</a>
    <hr/>
    <a th:href="@{'/show2?id='+${id}+'&name='+${name}}">普通 URL 格式传参三</a>
    <hr/>
    <a th:href="@{/show2(id=${id},name=${name})}">普通URL传递参数方式四</a>

    <h1>URL中Restful方式参数传递：</h1>
    <hr/>
    <a th:href="@{/show3/{id}(id=200)}">restful格式传递参数方式一</a>
    <hr/>
    <a th:href="@{/show3/{id}/{name}(id=200,name=admin)}">restful格式传递参数方式二</a>
    <hr/>
    <a th:href="@{/show4/{id}(id=200,name=admin)}">restful格式传递参数方式三</a>
    <hr/>
    <a th:href="@{/show4/{id}(id=${id},name=${name})}">restful格式传递参数方式四</a>
</body>
</html>